package com.twobu.twobuinsight.controller;

import com.twobu.twobuinsight.common.Result;
import com.twobu.twobuinsight.common.errorcode.CommonErrorCode;
import com.twobu.twobuinsight.exception.BusinessException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author l'y'k
 * @version 1.0
 * @description: TODO
 * @date 2025-06-11 14:13
 */
@RestController
public class TestController {
    @GetMapping("/test")
    public String test(){
        return "Hel1ow World!";
    }

    @GetMapping("/test/exception")
    public Result<Void> testException() {
        // 测试业务异常
        throw BusinessException.of(CommonErrorCode.BUSINESS_ERROR);
    }

    @GetMapping("/test/custom-exception")
    public Result<Void> testCustomException() {
        // 测试自定义错误信息的业务异常
        throw BusinessException.of(600, "这是一个自定义的业务异常");
    }
}
